function [date]=finddate(frTime,noday,id)
%  code nay tuy co cach ngan hon la lay nguyen quy nhung lam ton bo nho
dem=0;
while noday>0&&dem<100
    dem=dem+1;
    fromTime=datenum(frTime,'dd/mm/yyyy')-1;
    frTime=datestr(fromTime,'dd/mm/yyyy');
    tem=get_info_from_database('security', 'sec_id', id , ...
        'from', frTime, 'to', frTime);
    if (isempty(tem)==0)
        noday=noday-1;
    end
end
if dem<100
date=frTime
else
    date='Lam gi co ngay nay, data khong du'
end
